﻿using System.Diagnostics;
using System.Drawing;
using System.Windows.Forms;

namespace ReAnimation.Controls
{
    public partial class FlatButton : UserControl
    {
        private static readonly Color DefaultMouseHoverColor = Color.LightBlue;
        private static readonly Color DefaultMouseDownColor = Color.Blue;
        private static readonly Color DefaultNormalColor = Color.MediumBlue;

        public Color MouseHoverColor { get; set; }
        public Color MouseDownColor { get; set; }
        public Color NormalColor { get; set; }
        public Label TitleLabel { get { return titleLabel;} }
        public string Title
        {
            get
            {
                return TitleLabel.Text;
            }
            set
            {
                TitleLabel.Text = value;
            }
        }

        public FlatButton()
        {
            MouseHoverColor = DefaultMouseHoverColor;
            MouseDownColor = DefaultMouseDownColor;
            NormalColor = DefaultNormalColor;
            BackColor = NormalColor;
            InitializeComponent();
        }

        private void FlatButton_MouseEnter(object sender, System.EventArgs e)
        {
            BackColor = MouseHoverColor;

        }

        private void FlatButton_MouseHover(object sender, System.EventArgs e)
        {
            BackColor = MouseHoverColor;
        }

        private void FlatButton_MouseLeave(object sender, System.EventArgs e)
        {
            BackColor = NormalColor;
        }

        private void FlatButton_MouseUp(object sender, MouseEventArgs e)
        {
            if (Bounds.Contains(Parent.PointToClient(Cursor.Position)))
                BackColor = MouseHoverColor;
            else
                BackColor = NormalColor;
           
        }

        private void FlatButton_MouseDown(object sender, MouseEventArgs e)
        {
            BackColor = MouseDownColor;
        }

        private void FlatButton_Enter(object sender, System.EventArgs e)
        {
            
        }

        private void FlatButton_Leave(object sender, System.EventArgs e)
        {
            BackColor = NormalColor;
        }
    }
}
